Page({
  data: {
    actions: [{
      name: "我的博客"
    }, {
      name: "退出登录"
    }],
    name: "",
    avatar: "/images/avatar.jpg"
  },
  onLoad() {
    const userInfo = wx.getStorageSync("userInfo");
    if (!userInfo) {
      wx.navigateTo({
        url: '/pages/login/login',
      })
    }
    this.setData({
      name: userInfo.name
    });
  },
  logout() {
    // 清除缓存
    wx.clearStorageSync();
    // 跳转到首页
    wx.reLaunch({
      url: '/pages/index/index',
    })
  }
})